package component.change
{
	import baseInterface.functional.Iable;
	/**
	 *功能管理器 
	 * @author Chita
	 * 
	 */	
	public class ADmultAbleMng 
	{
		private var _typeVec:Vector.<Class>=new Vector.<Class>
		private var _vec:Vector.<Iable>=new Vector.<Iable>;
		public function ADmultAbleMng()
		{
		}
		
		public function get lenAble():int
		{
			return _vec.length;
		}
		
		public function addAble(value:Iable):Boolean
		{
			if(_vec.indexOf(value)>0)
				return false;
			_typeVec.push((value as Object).constructor);
			_vec.push(value);
			return true;
		}
		
		public function removeAble(value:Class):void
		{
			var index:int=_typeVec.indexOf(value)
			if(index<0)return
			_typeVec.splice(index,1);
			_vec.splice(index,1);
		}
		/**
		 * 设置 全部功能可用 
		 * @param type
		 * @param value
		 * 
		 */		
		public function setenableAble(type:Class,value:Boolean):void
		{
			var _ab:Iable=getAbleItem(type);
			if(_ab)_ab.isable=value;
		}
		private function getAbleItem(type:Class):Iable
		{
			var index:int=_typeVec.indexOf(type)
			if(index<0)return null
			return _vec[index];
		}
		public function isEnable(type:Class):Boolean
		{
			var _ab:Iable=getAbleItem(type);
			return Boolean(_ab); 
		}
		public function getAbleIndex(ab:Iable):int
		{
			return _vec.indexOf(ab);
		}
		public function isDoit(type:Class):Boolean
		{
			if(isEnable(type))
			return getAbleItem(type).isDoit
			return false;
		}
	}
}